package com.init;

import com.kafka.SendDataToKafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.kafka.ReceiveKafkaData;

import java.util.Arrays;

/**
 * Created by wanye on 2017/6/3.
 */
@Component
@Order(1)
public class InitConfig implements CommandLineRunner {

    public static SendDataToKafkaProducer simpleKafkaProducer;//初始化

    @Override
    public void run(String... args) throws Exception {
        try {
            logger.info("begin 测试写入数据到redis");
            //RedisPool.main(null);
            //simpleKafkaProducer = new SendDataToKafkaProducer();

            logger.info("begin 启动加载发送kafka生产端");
            ReceiveKafkaData.main(null);//后面的程序将挂起，所以其他程序不能放到此程序后面
            logger.info("end 启动加载发送kafka生产端");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    final static Logger logger = LoggerFactory.getLogger(InitConfig.class);
}